﻿using Zy.Shared.Repository.Register;

namespace Zy.User.Repository.Registers;

/// <summary>
/// Registers database services.
/// </summary>
public static class RegisterRepository
{
    /// <summary>
    /// Adds DbContext services to the dependency injection container.
    /// </summary>
    /// <param name="services">The service collection.</param>
    /// <param name="serviceInfo">Service information including lifecycle options.</param>
    /// <param name="config">Configuration containing connection strings and sharding rules.</param>
    /// <returns>The updated service collection.</returns>
    public static IServiceCollection AddDbcontextServices(
        this IServiceCollection services,
        ServiceInfo serviceInfo,
        IConfiguration config)
    {
        // Registers ShardingCore's DbContext services for handling operations across multiple database instances.
        services.AddShardingCoreDbcontextServices<EntityInfo>(config, serviceInfo);

        // Adds ClickHouse database services to the dependency injection container using EntityInfo as the entity type.
        services.AddZySqlSugarCoreClickHouse<EntityInfo>(config);

        return services;
    }
}